﻿#region namespaces

using Db4objects.Db4o.Activation;
using Db4objects.Db4o.TA;

#endregion

namespace ZOIL.DataBackend.Db4o
{
    public class BaseActivatable : IActivatable
    {
        #region IActivatable Members

        [System.NonSerialized] private IActivator _activator;

        public void Activate(ActivationPurpose purpose)
        {
            if (_activator == null)
            {
                return;
            }
            _activator.Activate(purpose);
        }

        public void Bind(IActivator activator)
        {
            if (_activator == activator)
            {
                return;
            }
            if (activator != null && null != _activator)
            {
                throw new System.InvalidOperationException();
            }
            _activator = activator;
        }

        #endregion
    }
}